#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include <unordered_map>
using namespace std;


class MyEnvironment : public testing::Environment {
public :
    virtual void SetUp() override { // 在所有的测试之前调用
        cout << "单元测试执行前的环境初始化!!" << endl;
    }
    virtual void TearDown() override {
        cout << "单元测试执行完毕后的环境清理!!!" << endl;
    }

private :

};

TEST(MyEnvironment, test1) {
    cout << "单元测试1" << endl;
}

TEST(MyEnvironment, test2) {
    cout << "单元测试2" << endl;
}


unordered_map<string, string> dict;

class MyMapTest : public testing::Environment {
public :
    virtual void SetUp() override { // 在所有的测试之前调用
        cout << "单元测试执行前的环境初始化!!" << endl;
        dict["hello"] = "你好";
        dict["apple"] = "苹果";
        dict["left"] = "左边";
        dict["right"] = "右边";
    }
    virtual void TearDown() override {
        cout << "单元测试执行完毕后的环境清理!!!" << endl;
        dict.clear();
    }

private :

};


TEST(MyMapTest, test1) {
    ASSERT_EQ(dict.size(), 4); // 判断是否相等
    dict["answer"] = "答案";
}

TEST(MyMapTest, test2) {
    ASSERT_EQ(dict.size(), 4); // 判断是否相等
}



int main(int argc, char* args[]) {
    testing::InitGoogleTest(&argc, args);
    testing::AddGlobalTestEnvironment(new MyMapTest());
    testing::AddGlobalTestEnvironment(new MyEnvironment());
    RUN_ALL_TESTS();

    return 0;
}